<html>
    <head>
        <meta charset="utf8" />
        <title>上传图片</title>
        <script src="./jquery-3.3.1.js"></script>
    </head>
    <body>
        <form action="" method="GET">
            <div class="choose">
                <label>请选择上传的群类型</label>
            </div>
            <button type="submit" >开始上传</button>
        </form>
    </body>
    <script type="text/javascript">
        $("form").submit(function(){
            $("button[type='submit']").attr("disabled","disabled");
            type=$(":selected").attr("data-type");
            data=$("form").serialize();
            if(type==="" || type==undefined){
                alert("请先选择群类型");
                return false;
            }
            $.ajax({
                url:"./Upload.php?"+data+"&type="+type,
                dataType:"json",
                type:"GET",
                success:function(data){
                    $("button[type='submit']").removeAttr("disabled");
                    alert(data.msg);
                },
                error:function(XMLHttpRequest){
                    $("button[type='submit']").removeAttr("disabled");
                    alert(XMLHttpRequest.responseText);
                }
            });
            return false;
        });
        $(document).ready(function(){
            $.ajax({
                url:"./getTypeData.php",
                dataType:"json",
                type:"GET",
                "success":function(data){
                    if(data.status==0){
                        alert(data.msg);
                    }else{
                        html="<select name='id' >";
                        data=data.data;
                        for(i in data){
                            name=data[i]["name"];
                            type=data[i]["en_name"];
                            id=data[i]["id"];
                            html=html+"<option value='"+id+"'"+" "+"data-type='"+type+"'"+" "+">"+name+"</option>";
                        }
                        html=html+"</select>";
                        $(".choose label:first ").after(html);
                    }
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    alert(XMLHttpRequest.responseText);
                }
            });
        });
    </script>
</html>